// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property, executeInEditMode} = cc._decorator;

@ccclass
@executeInEditMode // 设置script脚本在编辑器中可以执行，并预览效果
export default class NewClass extends cc.Component {
    
    onLoad () {}

    start () {
        this.draw();
    }

    draw(){
        const g: cc.Graphics = this.node.getComponent(cc.Graphics);

        g.moveTo(0, 0);
        g.lineTo(200, 0);
        g.lineTo(200, 200);
        g.close();
        g.fillColor = new cc.Color().fromHEX('#ffff00'); // 设置填充颜色
        g.fill();

        g.moveTo(0, 0)
        g.lineTo(-200, 0);
        g.lineTo(-200, -200);
        g.close();

        g.lineWidth = 5;
        g.strokeColor = new cc.Color().fromHEX('#ffff00'); // 设置线条颜色
        g.stroke(); // 最终绘制
    }

    // update (dt) {}
}
